#include "singleton.h"
#include <thread>

hanger::Singleton hanger::Singleton::instance;
void testHanger()
{
    hanger::Singleton* sig = hanger::Singleton::getInstance();
    sig->doSomething();
    hanger::Singleton::getInstance()->doSomething();
}

void testLazy()
{
    using namespace lazy;
    auto ins = Singleton::getInstance();
    
    std::thread t1([]()
    {
        auto ins = Singleton::getInstance();
    });

    std::thread t2([]()
    {
        auto ins = Singleton::getInstance();
    });

    t1.join();
    t2.join();
}

void testLazyElegant()
{
    using namespace lazy_elegant;
    Singleton::getInstance().doSomething();
    Singleton::getInstance().doSomething();
    Singleton::getInstance().doSomething();

    std::thread t1([]()
    {
        Singleton::getInstance().doSomething();
    });

    std::thread t2([]()
    {
        Singleton::getInstance().doSomething();
    });

    t1.join();
    t2.join();
}

int main()
{
    testLazyElegant();
    return 0;
}